package com.example.attempt.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;

import java.time.LocalDateTime;

@Data
public class Homework {
    @TableId(value = "hid",type = IdType.AUTO)
    private int hid;
    private String tid;
    private String cid;     // 表示返回时间类型
    @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")      // 表示接收时间类型
    private LocalDateTime hTime;
    private String content;
    private String hlink;
    private String title;
    private float studentRate=0;
    private float teacherRate=1;
    private float assistanceRate=0;
    private int submitNumber=0;
    private double threshold=0;
    private int isDistribute=0;
    @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private LocalDateTime dtime;
    private int isPublish=0;
    private int isCheck=0;

    public Homework(int hid, String tid, String cid, LocalDateTime hTime, String title,
                    String content, String hlink, float studentRate, float teacherRate,
                    float assistanceRate, double threshold, int isDistribute,
                    LocalDateTime dtime, int isPublish, int isCheck){
        this.teacherRate=1;
        this.studentRate=0;
        this.assistanceRate=0;
        this.tid=tid;
        this.cid=cid;
        this.hid=hid;
        this.hlink=hlink;
        this.hTime=hTime;
        this.title=title;
        this.content=content;
        this.threshold=0.5;
        this.submitNumber=0;
        this.isDistribute=0;
        this.dtime=null;
        this.isPublish=0;
        this.isCheck=0;
    }

    public Homework(HomeworkWithFile h,String link){
        this.cid=h.getCid();
        this.hid=0;
        this.content=h.getContent();
        this.hTime=h.getHtime();
        this.tid=h.getTid();
        this.hlink=link;
        this.title=h.getTitle();
        this.studentRate=0;
        this.assistanceRate=0;
        this.teacherRate=1;
        this.threshold=0.5;
        this.isDistribute=0;
        this.submitNumber=0;
        this.dtime=null;
        this.isPublish=0;
        this.isCheck=0;
    }

    public void setTitle(String title) {
        this.title = title;
    }

}
